package com.llkj.contractmanagement.contractmanagement.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.llkj.contractmanagement.R;
import com.llkj.contractmanagement.model.ContractListBean;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * author: dong.yj
 * created on: 2016/8/17 10:19
 * description:搜索结果页面数据适配器
 */
public class SearchResultAdapter extends CommonBaseAdapter<SearchResultAdapter.ViewHolder,ContractListBean.HtlistBean> {

    public SearchResultAdapter(Context context, List<ContractListBean.HtlistBean> list) {
        super(context, list);
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int position) {
        return new ViewHolder(inflate(R.layout.lv_search_result_item, null));
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        ContractListBean.HtlistBean htlistBean = mList.get(position);
        if (htlistBean.getSign().equals("1")) {
            holder.ivPhoto.setImageResource(R.drawable.icon_pdf);
        }else if (htlistBean.getSign().equals("2")) {
            holder.ivPhoto.setImageResource(R.drawable.icon_word);
        }
        holder.tvTitle.setText(htlistBean.getName());
    }

    static class ViewHolder extends CommonBaseAdapter.ViewHolder {

        @Bind(R.id.iv_search_result_img)
        ImageView ivPhoto;
        @Bind(R.id.tv_search_result_name)
        TextView tvTitle;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(view);
        }
    }
}
